package br.org.etec.dotcao.service;

import br.org.etec.dotcao.model.State;
import br.org.etec.dotcao.model.User;
import br.org.etec.dotcao.service.jpa.ServiceImpl;
import br.org.etec.dotcao.service.jpa.StateServiceImpl;
import br.org.etec.dotcao.service.jpa.UserServiceImpl;

public class ServiceFactory {
	
	@SuppressWarnings("unchecked")
	public static <T> Service<T> get(Class<T> type){
		if(User.class.isAssignableFrom(type)){
			return (Service<T>) new UserServiceImpl();
		}

		if(State.class.isAssignableFrom(type)){
			return (Service<T>) new StateServiceImpl();
		}
		
		return new ServiceImpl<T>(type);
	}

}
